

alter trigger [dbo].[tft_cashdaybook_ai] on [dbo].[tft_cashdaybook] 
after insert 
as   
begin
  set nocount on

  declare @accountid int
  declare cur_tft_cashdaybook cursor local forward_only static optimistic 
  for select distinct accountid from inserted
  open cur_tft_cashdaybook
  fetch next from cur_tft_cashdaybook into @accountid
  while @@fetch_status = 0
  begin
    exec p_cashdaybook_sumbalance @accountid   
    fetch next from cur_tft_cashdaybook into @accountid
  end
ERR:  
  close cur_tft_cashdaybook
  deallocate cur_tft_cashdaybook     
    
end
